import Page
from Page import Xting
from Base.Base import Base
from selenium.webdriver.common.by import By


class XtingRankPage(Base):
    """
    想听-排行榜页面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 列表标签标题, 默认选择第1个, 取值范围[1,10]
        self.rank_list_tag_title_text = (By.XPATH, Xting.rank_list_tag_title_text.format(1))

    def get_list_tag_text(self, index=1):
        """
        获取排行榜页面的指定索引的标签

        :param index: 标签的索引, 取值范围: 1~10
        :return: 元素对象
        """

        self.rank_list_tag_title_text = (By.XPATH, Xting.rank_list_tag_title_text.format(index))

        return self.find_element_o(self.rank_list_tag_title_text)

    def click_list_tag_text(self, index=1):
        """
        点击排行榜页面的指定索引的标签

        :param index: 标签的索引, 取值范围: 1~10
        :return: None
        """
        self.rank_list_tag_title_text = (By.XPATH, Xting.rank_list_tag_title_text.format(index))

        self.click_element(self.rank_list_tag_title_text)


if __name__ == '__main__':
    pass
